package com.breezelin.card.app.adapterview;

/**
 * Created by Breeze Lin
 * 2016/11/29 20:15
 * 1linyufeng1@gmail.com
 */

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.breezelin.card.app.R;
import com.breezelin.card.adapterview.model.CardModel;
import com.breezelin.card.adapterview.view.CardStackAdapter;

import java.util.ArrayList;

/**
 * 卡片适配器。定制。
 */
public class CardAdapter extends CardStackAdapter {

	private Context context;

	public CardAdapter(Context context, ArrayList<CardModel> models) {
		super(context, models);
		this.context = context;
	}

	@Override
	public int getCount() {
		return super.getCount();
	}

	@Override
	protected View getCardView(int position, CardModel model, View convertView, ViewGroup parent) {
		ImageView ret = new ImageView(context);
		ret.setLayoutParams(
				new ViewGroup.LayoutParams(
						(int) context.getResources().getDimension(R.dimen.card_width),
						(int) context.getResources().getDimension(R.dimen.card_height)
				)
		);
		ret.setImageResource(R.mipmap.ic_launcher);
		ret.setBackgroundResource(R.drawable.bg_card);
		return ret;
	}
}
